package com.chinasoft.mall.service;

import java.util.Observable;
import java.util.Observer;

import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;

import com.chinasoft.mall.framework.Config;
import com.chinasoft.mall.framework.LivingGoods;
import com.chinasoft.mall.model.response.EpgBean;
import com.chinasoft.mall.receiver.myBroadCast;

@SuppressLint("HandlerLeak")
public class ReflushDateService extends Service implements Observer{
	
	
	 Handler myHandler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				Intent intent = new Intent(myBroadCast.ACTION_INTENT_TEST);
				intent.putExtra(Config.INTENT_OBJ, ((EpgBean)msg.obj));
				sendBroadcast(intent);
			}
		};
	
	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}
	
	@Override
	public void onStart(Intent intent, int startId) {
		super.onStart(intent, startId);
		LivingGoods.getInstance().addObserver(this);
	}
	
	@Override
	public void onDestroy() {
		super.onDestroy();
	}

	@Override
	public void update(Observable observable, Object data) {
		int refreshtype = (Integer) data;
		if (refreshtype == LivingGoods.Refresh_TS) {
			Message message=new Message();
			message.obj=LivingGoods.getInstance()
			.getEb();
			myHandler.sendMessage(message);
		}
	}
}
